import request from '@/api/http.js'

// 获取工单列表数据详情 
export const WorkOrderSearchListDetail = (id) =>{
    return request.get('api/ProductionWorkOrder/getDetailPageData?id='+id)
}

// 获取工单列表数据
export const WorkOrderSearchList = (params) =>{
    console.log('工单列表发送参数:', params)
    const query = new URLSearchParams(params).toString();
    return request.get(`api/ProductionWorkOrder/getPageDate?${query}`)
}


//获取存货数据
export const getInventory = (params) => {
  return request.post('api/Inventory/getPageData', params)
}

//获取工序数据
export const getProcess = (params) => {
    return request.post('api/Process/getPageData', params)
}

// 获取工单编号
export const getProcessCode = () => {
    return request.get('api/ProductionWorkOrder/GetProductionWorkOrder')
}

// 新增工单
export const addProcess = (params) => {
    console.log('addProcess发送参数:', params)
    return request.post('api/ProductionWorkOrder/AddProductionWorkOrder',params)
}

// 更改工单状态
export const changeWorkStatus = (params) => {
    console.log('changeWorkStatus发送参数:', params)
    return request.post('api/ProductionWorkOrder/ChangeProductionWorkOrderStatus',params)
}

// 获取报工列表数据
export const GetReportWork = (params) =>{
    console.log('工单列表发送参数:', params)
    const query = new URLSearchParams(params).toString();
    return request.get(`api/ReportWork/getPageDate?${query}`)
}
// 获取报工详情
export const ReportSearchListDetail = (id) =>{
    return request.get('api/ReportWork/getDetailPageData?id='+id)
}

// 获取单位
export const getUnit = (params) => {
    return request.post('api/Unit/getPageData',params)
}

// 获取员工
export const getEmployee = (params) => {
    return request.post('api/Employees/getPageData',params)
}

export const getDefectItem = () => {
    return request.get('api/DefectItem/getPageData', {
      page: 1,
      rows: 10000,
      sort: 'CreateDate',
      order: 'desc',
      defectItemCode: ''
    })
  }

  // 删除报工单
  export const deleteReportWork = (id) => {
    console.log('删除传递id:', id)
    return request.post(`api/ReportWork/Delete/${id}`)
  }

  // 新增报工单
  export const addReportWork = (params) => {
      console.log('addReportWork:', params)
      return request.post('api/Production_ReportWorkOrder/AddProductionReportWorkOrder',params)
  }

  export const selectInventory = (id) => {
    return request.get('api/Inventory/get?id=' + id)
  }

  // 通过工单Id返回工序信息
export const getProcessInfoByWorkOrderId = (id) => {
    return request.post(`api/Production_ReportWorkOrder/GetProcessInfoByWorkOrderId/${id}`)
  }

// 获取报工可用数
export const getReportAvailableQuantity = (params) =>{
    console.log('工单列表发送参数:', params)
    const query = new URLSearchParams(params).toString();
    return request.get(`api/Production_ReportWorkOrder/GetReportAvailableQuantity?${query}`)
}

//获取班组管理列表
export const getTeamInfoList = (params) => {
    console.log('changeWorkStatus发送参数:', params)
    const query = new URLSearchParams(params).toString();
    return request.get(`api/Team/GetTeamInfoList?${query}`)
}

//获取设备管理列表
export const getVendInfoList = (params) => {
    console.log('changeWorkStatus发送参数:', params)
    const query = new URLSearchParams(params).toString();
    return request.get(`api/Vend/GetVendInfoList?${query}`)
}